<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Support\Facades\Input;
use App\Http\Controllers\Controller;

class CommonController extends Controller
{

    public function upload(){
        $file = Input::file('Filedata');
        if($file->isValid()){
            $extension = $file->getClientOriginalExtension(); //上传文件的后缀
            $nowName = date('His').'.'.$extension;
            $nowPath = base_path().'/upload/article/'.date('Ym');

            if (!file_exists($nowPath)){
                mkdir($nowPath, 0777, true);
            }
            $path = $file->move($nowPath,$nowName);
            $file_path = '/upload/article/'.date('Ym').'/'.$nowName;
            return $file_path;
        }
    }
}
